<?php
//https://graph.facebook.com/1356257881067/comments
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');

$facebook = new Facebook(array(
    'appId' => FB_APP_ID,
    'secret' => FB_APP_SECRET,
    'cookie' => true
));

$session = $facebook->getSession();
$me = null;

//Check if there is a session. Ensure that even if there is a session, we don't know it's valid or not until we make api call
if($session){
    try{
        $me = $facebook->api('/me');
    }catch(FacebookApiException $e){
        error_log($e);
    }
}

//Buttongs
$logout_button = "<a href='".$facebook->getLogoutUrl()."'><img src='http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif'></a>"; 
$login_button = "<a href='".$facebook->getLoginUrl()."'><img src='http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif'></a>";

if(!$me){
    print $login_button;
    exit();
}else{
    print $logout_button;
}


if($me){
    
    print_r($facebook->api('/1356257881067/comments'));
    
}